package org.leo.dm.util.comm;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.leo.dm.util.exception.DmException;

public final class DateUtil {
	private static SimpleDateFormat formatter;
	
	public static String getSysDate(){
	    formatter = new SimpleDateFormat ("yyyyMMdd"); 
		return formatter.format(new Date());
	}
	
	public static String getSysDateFormat(String format){
		formatter = new SimpleDateFormat (format);
		return formatter.format(new Date());
	}
	
	public static String getSysDateTime(){
		formatter = new SimpleDateFormat ("yyyyMMddHHmmss"); 
		return formatter.format(new Date());
	}
	
	public static Date getSysDateFormat(String dateString,String format){
		formatter = new SimpleDateFormat (format);
		try {
			return formatter.parse(dateString);
		} catch (ParseException e) {
			new DmException("平台string转换date异常：",e);
		}
		return new Date();
	}
}
